/*
 * Things to highlight in the example:
 * 1. directly using java.util.*
 * 2. declaration is flexible and succinct
 * 3. event return type is Unit, better explicit declare it and add "="
 *    before {...} function body. without "=", function will be considered a "procedure"
 */

package helloscala.practise.chapter2

import java.util.HashMap
import java.util.Map

object JavaCollection {
  def createMaps = {
    val map1 = new HashMap[Integer, String]
    map1.put(2, "hello2")
    println(map1.get(2))

    val map2: Map[Integer, String] = new HashMap
    map2.put(3, "hello3")
    println(map2.get(3))
  }

  def createScalaMap: Unit = {
    var map1 = scala.collection.Map[Int, String]();
    map1 = map1.updated(4, "hello4") //map1.updated() will not change map1 itself

    println(map1.apply(4))
    println(map1.get(4));
  }
}
